<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title></title>
<link href="houtai/css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="houtai/js/main.js"></script>
<script type="text/javascript">
	var xmlhttp;
	function ajaxeditstate(uid) {
		var s = document.getElementById("state1" + uid).innerHTML;
		var ustate;
		var ss;
		if (s == "启用") {
			ustate = 1;
			ss = "禁用";
			
		}
		if (s == "禁用") {
			ustate = 0;
			ss = "启用";
			
		}
		if (confirm("是否" + ss + "吗?")) {

			if (s == "启用") {
				document.getElementById("state1" + uid).innerHTML = "禁用";
				document.getElementById("butsta" + uid).innerHTML = "启用";

			}
			if (s == "禁用") {
				document.getElementById("state1" + uid).innerHTML = "启用";
				document.getElementById("butsta" + uid).innerHTML = "禁用";
			}

			xmlhttp = new XMLHttpRequest();
			xmlhttp.open("get", "UserServlet?param=editstate&id=" + uid+ "&ustate=" + ustate + "&time=" + new Date().getTime(),true);
			xmlhttp.send(null);
		}

	}
	function breakpage(){
	
		var pa=document.getElementById("inpage").value;
		if(isNaN(pa)||pa.indexOf(' ')>=0||pa==""){
	  		alert("请输入数字！");
	    }else if(pa<0 || pa>${pi.lastPage}){
	         alert("该页面不在范围！请重新输入！");
	    }else{
	   
	    	window.location.href="<%=request.getContextPath()%>/UserServlet?param=showAll&page="+pa+"&time="+new Date().getTime();
	    }
	}
	function subselectinfo(){
	
		
		document.getElementById("form8").submit();
	}
	
	function ckfu(){
		var str=document.getElementsByName("checkbox4");
		
		for(var i=1;i<str.length;i++){
			str[i].checked=str[0].checked;
		}
	}
	
</script>

</head>
<body>
	<table width="100%" height="100%" border="0" cellspacing="0"
		cellpadding="3">
		<tr>
			<td style="height:25px; background-color:#f3f3f3; font-weight:bold"
				valign="top">&nbsp;&nbsp;&nbsp;&nbsp;当前位置： <img
				src="houtai/images/arrow.gif" align="absmiddle">&nbsp;&nbsp;soda创业教育平台&nbsp;&nbsp;
				<img src="houtai/images/arrow.gif" align="absmiddle">&nbsp;&nbsp;后台管理&nbsp;&nbsp;
				<img src="houtai/images/arrow.gif" align="absmiddle">&nbsp;&nbsp;用户管理
			</td>
		</tr>
		<tr>
			<td
				style="height:34px; background-image:url(houtai/images/main_header.gif); border-bottom:1px solid #cfd8e0; padding:0px">
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td width="20" height="34"><img
							src="houtai/images/main_headerL.gif" width="20" height="34"></td>
						<td style="color:#90c8e8;"><img
							src="houtai/images/icon_card.gif" width="16" height="16"
							align="absmiddle">&nbsp;&nbsp;<strong>用户管理</strong></td>
						<td align="right" class="white" style="padding-right:20px"><a
							href="<%=request.getContextPath()%>/RoleServlet?param=selectAllRole" class="barBtn" ><img
								src="houtai/images/5.png" align="absmiddle"> 新增</a> <a
							 class="barBtn" onClick="javascript:history.go(-1);"><img
								src="houtai/images/btn_left.gif" align="absmiddle"> 后退</a> <a
							 class="barBtn" onClick="javascript:history.go(+1);"><img
								src="houtai/images/btn_right.gif" align="absmiddle"> 前进</a> <a
							href="<%=request.getContextPath() %>/UserServlet?param=showAll" class="barBtn"><img
								src="houtai/images/btn_refresh.gif" align="absmiddle"> 刷新</a></td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td
				style="height:30px; background-color:#bddbff; border-bottom:1px solid #cfd8e0;"><table
					width="100%" border="0" cellpadding="3" cellspacing="1"
					class="table1">
					<form id="form8" action="<%=request.getContextPath() %>/UserServlet?param=showAll" method="post">
					<TR>
						<th width="10%" align="center">用户登录名</th>
						<td width="20%" class="BGCgray"><input type="text"
							name="loginname" id="loginname" value="${sessionScope.sui.loginname }"></td>
						<th width="10%" align="center">真实姓名</th>
						<td width="20%" class="BGCgray"><input type="text"
							name="uname" id="uname" value="${sessionScope.sui.uname }"></td>
						<th width="10%" align="center"><STRONG>状态</STRONG></th>
						<td width="20%" class="BGCgray"><select name="ustate"
							id="ustate" >
								<option value="2" ${sessionScope.sui.ustate==2?"selected='selected'":"" }>全部</option>
								<option value="1" ${sessionScope.sui.ustate==1?"selected='selected'":"" }>启用</option>
								<option value="0" ${sessionScope.sui.ustate==0?"selected='selected'":"" }>禁用</option>
						</select></td>
						<th width="10%" align="center"><BUTTON style="HEIGHT:25px" onclick="return subselectinfo()">
								<img src="houtai/images/btn_search.gif" width="16" height="16"
									align="absmiddle"> 查询
							</BUTTON></th>
					</TR>
					</form>
				</table></td>
		</tr>
		<tr>
			<td height="100%" valign="top">
				<div style="overflow:auto;height:100%; width:100%">
					<table width="100%" border="0" cellpadding="3" cellspacing="1"
						class="table1">
						<TR>
							<th align="center"><input type="checkbox" name="checkbox4" onclick="ckfu()"
								id="checkbox"></th>
							<th align="center">用户姓名</th>
							<th align="center">登录名</th>
							<th align="center">联系电话</th>
							<th align="center">地址</th>
							<th align="center">邮箱</th>
							<th align="center">状态</th>
							<th width="200" align="center">操作</th>
						</TR>
						<c:forEach items="${requestScope.users }" var="u">
						<c:if test="${u.useDelete!=0 }">
							<TR>
								<TD align="center"><input type="checkbox" name="checkbox4" onclick="ckzi(this)"
									id="checkbox2"></TD>
								<TD align="center">${u.useName }</TD>
								<TD align="center">${u.useLoginName }</TD>
								<TD align="center">${u.usePhone }</TD>
								<TD align="center">${u.useAddress }</TD>
								<TD align="center">${u.useEmail }</TD>
								<TD align="center" id="state1${u.useId }">${u.useState==1?"启用":"禁用" }</TD>
								<TD width="200" align="center"><BUTTON
										style="height:21px; font-size:12px"
										onClick="javascript:if (confirm('查看该信息？')) location.href='<%=request.getContextPath() %>/UserServlet?id=${u.useId }&param=showUserBuId&s=show';else return;">查看</BUTTON>
									<BUTTON style="height:21px; font-size:12px"
										onClick="javascript:if (confirm('编辑该信息？')) location.href='<%=request.getContextPath() %>/UserServlet?id=${u.useId }&param=showUserBuId&s=edit';else return;">编辑</BUTTON>
									<BUTTON id="butsta${u.useId }"
										style="height:21px; font-size:12px"
										onClick="ajaxeditstate(${u.useId})">${u.useState==0?"启用":"禁用" }</BUTTON>
									<BUTTON style="height:21px; font-size:12px"
										onClick="javascript:if (confirm('是否删除？')) location.href='<%=request.getContextPath() %>/UserServlet?param=daleteById&id=${u.useId}';else return;">删除</BUTTON></TD>
							</TR>
							</c:if>
						</c:forEach>


					</table>
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td width="20%" height="25"><table border="0"
									cellspacing="0" cellpadding="3">
									<tr>
										<td><c:if test="${pi.page<=1 }">首页</c:if>
										<c:if test="${pi.page>1 }"><a href="<%=request.getContextPath() %>/UserServlet?param=showAll&page=1" style="color:black;">首页</a></c:if></td>
										<td><c:if test="${pi.page<=1 }">上一页</c:if>
										<c:if test="${pi.page>1 }"><a href="<%=request.getContextPath() %>/UserServlet?param=showAll&page=${pi.page-1}" style="color:black;">上一页</a></c:if></td>
										<td>
									<c:forEach begin="1" end="${pi.lastPage}" varStatus="i"  >
									<c:if test="${pi.page==i.index }">${i.index }</c:if>
									<c:if test="${pi.page!=i.index }">
									<a style="color: #5CA4DF" href="<%=request.getContextPath() %>/UserServlet?param=showAll&page=${i.index}">${i.index }</a>
									</c:if>
									</c:forEach>
										
										</td>
										
										<td><c:if test="${pi.page>=pi.lastPage }">下一页</c:if>
										<c:if test="${pi.page<pi.lastPage }"><a href="<%=request.getContextPath() %>/UserServlet?param=showAll&page=${pi.page+1}" style="color:black;">下一页</a></c:if></td>
										<td><c:if test="${pi.page>=pi.lastPage }">尾页</c:if>
										<c:if test="${pi.page<pi.lastPage }"><a href="<%=request.getContextPath() %>/UserServlet?param=showAll&page=${pi.lastPage}" style="color:black;">尾页</a></c:if></td>
									</tr>
								</table></td>
							<td width="20%" align="center">
								<table border="0" cellspacing="0" cellpadding="3">
									<tr>
									
										<td><a href="javascript:breakpage();" style="color:black;">GO</a></td>
										<td><input id="inpage" name="inpage" type="text" size="3" style="width:25;height:18"> /页</td>
									</tr>
									
								</table>
							</td>
							<td width="20%" align="right">共${pi.total }条记录,当前第${pi.page }页，共${pi.lastPage }页</td>
						</tr>
					</table>
				</div>
			</td>
		</tr>
	</table>
</body>
</html>